home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FrazBinaryFormatPlugins.h
-
- Fragmalyzer Binary Format Plug-in (BFX) Interface
-
- Version: 1.5
- Date: September 2000
-
- Copyright © 2000 Dan Wright, All rights reserved.
-
- Bugs?: Please include the name of this file, the version, and the date (above).
- Send bug reports to danwr@kagi.com.
-
- Updates: http://www.halcyon.com/danwr/smoothie.html
-
- Binary Format Plug-ins (BFX) provide support for binary formats. A standard BFX included
- with the Framalyzer 1.5 provides support for PEF fragments; other formats include COFF,
- XCOFF (extended COFF), and Mach-O.
-
- In addition, a BFX may provide support for certain run-time architecture features, such as
- searching for libraries.
- */
-
- #ifndef __FRAZBINFORMAT__
- #define __FRAZBINFORMAT__
-
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #include <Navigation.h>
-
- #include "FrazBinaries.h"
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT
- #pragma import on
- #endif
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
- #endif
-
-
- enum {
- #if TARGET_API_MAC_CARBON
- kFrazBFXCurrentVersion = 2,
- #else
- kFrazBFXCurrentVersion = 1,
- #endif
-
- #if TARGET_RT_MAC_CFM
- #if TARGET_API_MAC_CARBON
- kFrazBFXCallbackMagic = FOUR_CHAR_CODE('bfx*')
- #else
- kFrazBFXCallbackMagic = FOUR_CHAR_CODE('abi*')
- #endif
- #else
- kFrazBFXCallbackMagic = FOUR_CHAR_CODE('bfx!')
- #endif
- };
-
- typedef struct OpaqueScanContext * FrazScanContext;
-
- typedef struct OpaqueSymbol * SymbolRef;
-
-
- enum {
- // properties that have special types not for AppleScript consumption
- kFrazPropTypePrivate = FOUR_CHAR_CODE(']]]]'),
- // properties that have special types not for AS and cannot be modified exc. by BFX
- kFrazPropTypePrivateReadOnly = FOUR_CHAR_CODE('[[[['),
- // properties that are completely invisible to anyone but the BFX
- kFrazPropTypePrivateInvisible = 0
- };
-
- typedef OSErr (*AddLocatorProcPtr)(FrazScanContext, BrowserRef, BinFormat, const FrazLocator *, ConstStr255Param);
- typedef OSErr (*RemoveFragmentProcPtr)(FrazScanContext, FragmentRef);
- typedef OSErr (*AddInformationProcPtr)(FragmentRef, OSType, void *, Size);
- typedef OSErr (*SetSectionPropertyProcPtr)(FragmentRef, SInt16 section, OSType property, DescType, void *pvalue, Size cbValue);
- typedef OSErr (*AddLibraryProcPtr)(FragmentRef, ConstStr255Param stLibrary, LibraryRef *plibrary);
- typedef OSErr (*SetLibraryPropertyProcPtr)(LibraryRef, OSType property, DescType, void *pvalue, Size cbValue);
- typedef OSErr (*AddSymbolProcPtr)(FragmentRef, LibraryRef, ConstStr255Param stSymbol, SymbolRef *psymbol);
- typedef OSErr (*SetSymbolPropertyProcPtr)(SymbolRef, OSType property, DescType, void *pvalue, Size cbValue);
- typedef OSErr (*SetFragmentPropertyProcPtr)(FragmentRef, OSType, DescType, void *, Size);
-
-
- enum { /* FrazFilterParam.flags, FrazScanParam.flags */
- kFrazSharedLibrariesOnlyMask = 0x0001,
- kFrazNeverInteractMask = 0x0002, /* always set in FrazFilterParam.flags */
- kFrazSearchingMask = 0x0004, /* window shopping: we don't need a clerk yet, thank you very much */
- kFrazValidationBasicMask = 0x0010, /* verify basic fragment structure (scan only) */
- kFrazValidationWarningsMask = 0x0020 /* further validation */
- };
-
- enum { /* FrazFilterParam.where */
- kFrazFileSpec = 1,
- kFrazNavSpec,
- kFrazProcess,
- kFrazContext
- };
-
- typedef struct FrazFilterParam
- {
- UInt16 flags;
- UInt16 where;
- union {
- struct {
- ConstFSSpecPtr pfile;
- CInfoPBPtr catInfo;
- } fileSpec; /* 8 */
- struct {
- const AEDesc * paeDesc;
- const NavFileOrFolderInfo *navInfo;
- } navSpec; /* 8 */
- ProcessSerialNumber process; /* 8 */
- CFragContextID context; /* 4 */
- } u;
- } FrazFilterParam;
-
- typedef struct FrazScanParam
- {
- UInt16 flags;
- UInt16 where;
- union {
- ConstFSSpecPtr pfileSpec;
- ProcessSerialNumber process;
- CFragContextID context;
- } u;
- } FrazScanParam;
-
- typedef struct FrazFindParam
- {
- UInt16 flags;
- UInt16 reserved;
- BinFormat binFormat;
- FragmentRef fragment;
- LibraryRef library;
- } FrazFindParam;
-
-
- typedef struct FrazLibSearch
- {
- UInt32 privateData[4];
- } FrazLibSearch;
-
- enum {
- kDontCacheThisSearch = 0
- };
-
- /*
- prototypes for BFX entrypoints
- */
-
- /* BFXFilter - determines which files/processes contain fragments of the supported binary format (required) */
- Boolean BFXFilter(const FrazFilterParam *);
-
- /* BFXScan - identifies all fragments of our binary format in the specified file/process (required)
- If no fragments are found, should return errNoFragmentsFound instead of noErr. */
- OSErr BFXScan(FrazScanContext, const FrazScanParam *);
-
- /* BFXGetFragmentInfo - identifies libraries, section, and fragment properties of the specified fragment (required) */
- OSErr BFXGetFragmentInfo(FrazScanContext, FragmentRef, ConstFrazLocatorPtr);
-
- /* BFXGetImportedSymbols - builds the list of imported symbols (optional) */
- OSErr BFXGetImportedSymbols(FrazScanContext, FragmentRef, LibraryRef, ConstFrazLocatorPtr);
-
- /* BFXGetExportedSymbols - builds the list of exported symbols (optional) */
- OSErr BFXGetExportedSymbols(FrazScanContext, FragmentRef, ConstFrazLocatorPtr);
-
- /* BFXGetSymbolProperty - obtains one property (in AEDesc form) for the specified symbol (optional) */
- OSErr BFXGetSymbolProperty(FrazScanContext, FragmentRef, LibraryRef, ConstFrazLocatorPtr,
- UInt32 indexSymbol, ConstStr255Param stMangled,
- OSType property, AEDesc *);
-
- /* BFXGetFragmentSizeReal - determines the exact size (in bytes) of the specified fragment (optional) */
- OSErr BFXGetFragmentSizeReal(FrazLocatorRef, UInt32 *pcb);
-
-
- /* BFXFind/BFXFindLibrary - locate the library (optional) */
- OSErr BFXFind(FrazScanContext, const FrazFindParam *);
- OSErr BFXFindLibrary(FrazScanContext, BinFormat, FragmentRef, LibraryRef);
-
- /*
- APIs available exclusively to Binary Format Plug-ins
- */
- pascal OSErr FrazAddLocator(FrazScanContext, BrowserRef, BinFormat, const FrazLocator *, ConstStr255Param);
- pascal OSErr FrazRemoveFragment(FrazScanContext, FragmentRef);
- pascal OSErr FrazSetFragmentProperty(FrazScanContext, FragmentRef, OSType property, DescType, void *, Size);
-
- pascal OSErr FrazAddSymbol(FrazScanContext, FragmentRef, LibraryRef, ConstStr255Param stSymbol, SymbolRef *psymbol);
- pascal OSErr FrazAddLibrary(FrazScanContext, FragmentRef, ConstStr255Param stLibrary, LibraryRef *plibrary);
- pascal OSErr FrazSetSymbolProperty(FrazScanContext, SymbolRef, OSType property, DescType, void *pvalue, Size cbValue);
- pascal OSErr FrazSetLibraryProperty(FrazScanContext, LibraryRef, OSType property, DescType, void *pvalue, Size cbValue);
- pascal OSErr FrazSetSectionProperty(FrazScanContext, FragmentRef, SInt16 section, OSType property, DescType type, void *pvalue, Size cbValue);
- pascal OSErr FrazSetLibraryIntegerProperty(FrazScanContext, LibraryRef, OSType property, long value);
- pascal OSErr FrazSetSectionIntegerProperty(FrazScanContext, FragmentRef, SInt16 section, OSType property, long value);
- pascal OSErr FrazSetFragmentIntegerProperty(FrazScanContext, FragmentRef, OSType property, long value);
- pascal OSErr FrazSetLibraryBooleanProperty(FrazScanContext, LibraryRef, OSType property, Boolean value);
- pascal OSErr FrazSetFragmentBooleanProperty(FrazScanContext, FragmentRef, OSType property, Boolean value);
- pascal OSErr FrazSetSymbolBooleanProperty(FrazScanContext, SymbolRef, OSType property, Boolean value);
- pascal OSErr FrazSetSymbolIntegerProperty(FrazScanContext, SymbolRef, OSType property, long value);
-
- /* Segment property support is not yet implemented: */
- pascal OSErr FrazSetSegmentProperty(FrazScanContext, FragmentRef, SInt16 segment, OSType property, DescType, void*, Size);
- pascal OSErr FrazSetSegmentIntegerProperty(FrazScanContext, FragmentRef, SInt16 segment, OSType property, long value);
- pascal OSErr FrazSetSegmentBooleanProperty(FrazScanContext, FragmentRef, SInt16 segment, OSType property, Boolean value);
-
- /* FrazScanContextIsValid - determines whether the context is (still) valid. It may become invalid, for example,
- if the browser window has been closed. */
- pascal Boolean FrazScanContextIsValid(FrazScanContext);
-
- /* FrazBrowserFromScanContext - determines the browser used for the context. Note: in some cases, there may
- be no browser associated with the context. */
- pascal BrowserRef FrazBrowserFromScanContext(FrazScanContext);
-
- /*
- library searches
- */
- pascal OSErr FrazBeginLibrarySearch(BinFormat, short vRefNum, long pluginSearchRefCon, FrazLibSearch *);
- pascal OSErr FrazAddFileToSearch(FrazLibSearch *, ConstFSSpecPtr);
- pascal OSErr FrazAddDirectoryToSearch(FrazLibSearch *, long dirID, short nSearchDepth, OSType ftyp);
- pascal OSErr FrazGetNextLibrary(FrazLibSearch *, ConstStr255Param stLibrary, FrazLocator *plocator);
- pascal OSErr FrazEndLibrarySearch(FrazLibSearch *);
-
-
-
-
-
-
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack()
- #endif
-
- #ifdef PRAGMA_IMPORT_OFF
- #pragma import off
- #elif PRAGMA_IMPORT
- #pragma import reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __FRAZBINFORMAT__ */